home *** CD-ROM | disk | FTP | other *** search
- /* touch.c -- similar to UNIX command */
-
- /* MS-DOS 3.1 & Lattice C 3.1 */
-
- #include "dos.h"
- #include "fcntl.h"
-
- void
- main(argc, argv)
- int argc;
- char *argv[];
- {
- int i;
- int fd; /* file descriptor */
- unsigned date, time; /* system date & time */
- union REGS regs; /* register to interrupt */
-
- for (i = 1; i < argc; i++) {
- fd = open(argv[i], O_RDWR | O_CREAT); /* open file */
-
- /* get system date */
- regs.h.ah = 42;
- int86(0x21, ®s, ®s);
- regs.x.ax = regs.x.cx;
- regs.x.ax -= 1980;
- regs.x.ax <<= 4;
- regs.h.al += regs.h.dh;
- regs.x.ax <<= 5;
- regs.h.al += regs.h.dl;
- date = regs.x.ax;
-
- /* get system time */
- regs.h.ah = 44;
- int86(0x21, ®s, ®s);
- regs.x.ax = 0;
- regs.h.al = regs.h.cl;
- regs.x.ax <<= 5;
- regs.h.ch <<= 3;
- regs.h.ah += regs.h.ch;
- regs.h.dh >>= 1;
- regs.h.al += regs.h.dh;
- time = regs.x.ax;
-
- /* set file date & time */
- regs.h.al = 1;
- regs.h.ah = 0x57;
- regs.x.dx = date;
- regs.x.cx = time;
- regs.x.bx = fd;
- int86(0x21, ®s, ®s);
-
- close(fd);
- }
- exit(0);
- }